package soundwave.com.demo.adpater;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.test.TakeoutfoodContent_test;

/**
 * Created by xu on 2017/4/1.
 */

public class TakeoutfoodContent_adapert extends ArrayAdapter<TakeoutfoodContent_test> {
    private Context context;
    private int layoutid;
    private LayoutInflater inflater;
    public TakeoutfoodContent_adapert(Context context, int resource,ArrayList<TakeoutfoodContent_test> takeoutfood) {
        super(context, resource,takeoutfood);
        this.layoutid=resource;
        this.context=context;
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=convertView;
        if (view==null){
            inflater=LayoutInflater.from(context);
            view=inflater.inflate(layoutid,null);
        }
        TakeoutfoodContent_test takeoutfoodContent_test=getItem(position);
        TextView adname= (TextView) view.findViewById(R.id.business_name);
        ImageView adimg= (ImageView) view.findViewById(R.id.business_img);

        adname.setText(takeoutfoodContent_test.getAdname());
        adimg.setImageResource(takeoutfoodContent_test.getAdimg());
        return view;
    }
}
